package org.sjs.dreamfly.player

import android.os.Bundle
import org.sjs.dreamfly.common.base.BaseFragment
import org.sjs.dreamfly.common.util.LogUtil
import org.sjs.dreamfly.common.util.Router

abstract class PlayerFragment: BaseFragment() {
    companion object {
        inline fun <reified T : PlayerFragment> newInstance(index: Int? = 0): T {
            LogUtil.d("index: $index")
            val fragment = T::class.java.getDeclaredConstructor().newInstance()
            if (index != null && index > 0) {
                fragment.arguments = Bundle().apply { putInt(Router.KEY_INDEX, index) }
            }
            return fragment
        }
    }

    protected var viewModel: IPlayerDataProvider? = null
    override fun onBindViews() {
    }

    override fun onInitViews() {
    }

    override fun onLoadData() {

    }

    fun setDataProvider(provider: IPlayerDataProvider) {
        viewModel = provider
    }

    open fun resumePlay() {

    }

    abstract fun saveHistory(): Boolean
}